package register;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import java.sql.*;

public class Control implements ActionListener {
	private static JFrame jf = new JFrame("王氏集团员工综合信息查询系统");
	private static JTextArea mas = new JTextArea(200, 200);// 用于显示查询到的信息
	private static JPanel jp = new JPanel(); 							// 该容器用存放各种按钮以及条件对话框
	static JTextField jtf = new JTextField(20);			//查询条件框
	static JLabel condition = new JLabel("查询条件");			
	static String[] word = {"全局查询","按姓查询","按工资升序查询"};
	static JComboBox choose = new JComboBox(word); 	//条件选择条
	
	public void actionPerformed(ActionEvent e) {
		String command = e.getActionCommand();
		if ("查   询".equals(command)) {
			Search.searchAll();
		}else if("上一页".equals(command)){
			
		}else if("下一页".equals(command)){
			
		}else if("退   出".equals(command)){
			System.exit(0);
		}
	}
	public Control() {
		
		
		mas.setEditable(false);	 // 设置信息提示框不可编辑
		mas.setColumns(10);	
		mas.setRows(10);
		JScrollPane jsp = new JScrollPane(choose);
		
		
		JPanel jpa = new JPanel();				//用来装选择条
		JPanel jpb = new JPanel();			//用来装按钮
		
		jpa.add(condition,FlowLayout.LEFT);
		jpa.add(jsp);
		jpa.add(jtf,FlowLayout.RIGHT);
		
		String[] but = {"查   询",
								"上一页",
								"下一页",
								"退   出" };
		for(int i=0; i<but.length; i++){
			JButton jb = new JButton(but[i]);
			jb.addActionListener(this);
			jpb.add(jb);
		}

		jp.add(jpa,BorderLayout.NORTH);		//将选择条件的的容器装到二级容器。
		jp.add(jpb,BorderLayout.CENTER);	//将按钮组的容器装到二级容器
		
		jf.add(jp, BorderLayout.NORTH);
		jf.add(mas, BorderLayout.SOUTH); 
		
		jf.setLocation(300, 200); 				// 设置出现位置
		jf.pack();										// 设置窗口大小
		jf.setVisible(true); 						// 设置可见
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	
	
	public static void main(String args[]) {
		new Control();
	}
}
